home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / doodle_d.swf / scripts / DefineSprite_31_en10 / frame_1 / DoAction.as
Text File  |  2013-04-24  |  2KB  |  68 lines

  1. function onEnterFrame()
  2. {
  3.    if(_root.shieldMC.hitTest(_X,_Y,true) && _root.shieldLevel >= 2)
  4.    {
  5.       dx = 0;
  6.       dy = 0;
  7.    }
  8.    distance = Math.sqrt((_X - _root.ship._x) * (_X - _root.ship._x) + (_Y - _root.ship._y) * (_Y - _root.ship._y));
  9.    if(distance < 300)
  10.    {
  11.       if(_X > 0 && _X < 640 && _Y < 880 && _Y > 0)
  12.       {
  13.          fx = _X - _root.ship._x + 1e-13;
  14.          fy = _Y - _root.ship._y;
  15.          radians = Math.atan(fy / fx);
  16.          if(_root.ship._x < _X)
  17.          {
  18.             radians -= 1.5707963267948966;
  19.          }
  20.          else
  21.          {
  22.             radians += 1.5707963267948966;
  23.          }
  24.          thrustDX = speed * Math.cos(radians);
  25.          thrustDY = speed * Math.sin(radians);
  26.          dx = thrustDX;
  27.          dy = thrustDY;
  28.       }
  29.       else
  30.       {
  31.          dx = 0;
  32.          dy = 0;
  33.       }
  34.    }
  35.    else
  36.    {
  37.       dx = 0;
  38.       dy = 0;
  39.    }
  40.    _X = _X + dx;
  41.    _Y = _Y + dy;
  42.    if(this.hitTest(_root.ship))
  43.    {
  44.       depth = _root.getNextHighestDepth();
  45.       _root.attachMovie("exp","exp" + depth,depth);
  46.       exp = eval("_root.exp" + depth);
  47.       exp._x = _X;
  48.       exp._y = _Y;
  49.       _root.death();
  50.       _root.eAmount--;
  51.       this.removeMovieClip();
  52.    }
  53.    if(h <= 0)
  54.    {
  55.       _root.eAmount--;
  56.       _root.points += 300;
  57.       _root.eD = _root.eD + 1;
  58.       depth = _root.getNextHighestDepth();
  59.       _root.attachMovie("exp","exp" + depth,depth);
  60.       exp = eval("_root.exp" + depth);
  61.       exp._x = _X;
  62.       exp._y = _Y;
  63.       this.removeMovieClip();
  64.    }
  65. }
  66. speed = 5;
  67. h = 10;
  68.